.PHONY: all clean

TARGET_CC ?= ${TC_PREFIX}gcc
CCFLAGS := -I../inc/

TARGET_OBJCOPY ?= ${TC_PREFIX}objcopy
TARGET_OBJDUMP ?= ${TC_PREFIX}objdump

LN ?= ln
ECHO ?= echo

all: ../target/boot_sect.bin ../target/boot_s1.bin

../target/boot_sect.bin: boot_sect.asm ../target/boot_s1.bin
	@${ECHO} make boot_sect.bin
	${V}sh make_boot_sect.sh

../target/boot_s1_asm.o: boot_s1_asm.S
	@${ECHO} CC $<
	${V}${TARGET_CC} ${CCFLAGS} $< -c -o$@

../target/boot_s1.o: boot_s1.c
	@${ECHO} CC $<
	${V}${TARGET_CC} ${CCFLAGS} $< -c -o$@

../target/boot_s1.bin: ../target/boot_s1_asm.o ../target/boot_s1.o
	@${ECHO} LD $@
	${V}${TARGET_LD} -N -e s1_asm_main -Ttext 0x8000 -o $@.out $^
	${V}${TARGET_OBJCOPY} -S -Obinary $@.out $@
	${V}${RM} $@.out
